/*
   Dark Lord
   Made by Buya
*/

void npc(Player @player, NPC @npc) {
	int state = npc.getState();
	if(state == 0) {
		if(player.getJob() == 0) {
			if(player.getLevel() >= 10) {
				npc.addText("Welcome. Have you come to become a Thief?");
				npc.sendYesNo();
			}
			else{
				npc.addText("You're too weak. Come back when you're at least level 10 and have a minimum of 25 dex.");
				npc.sendOK();
				npc.end();
			}
		}
		else if(player.getJob() == 400 && player.getLevel() >= 30) {
			if(player.getItemAmount(4031011) == 0) {
				if(player.getItemAmount(4031012) > 0) {
					npc.addText("I'm glad to see that you passed the test. Would you like to choose your next path now?");
					npc.sendYesNo();
				}
				else{
					npc.addText("I see that you're a lot stronger than you were when you first came here. Would you like to become even more powerful?");
					npc.sendYesNo();
				}
			}
			else{
				npc.addText("There are no shortcuts, you must pass the test or I won't help you.");
				npc.sendOK();
				npc.end();
			}
		}
		else{
			npc.addText("Remember, strength is your friend.");
			npc.sendOK();
			npc.end();
		}
	}
	else if(state == 1) {
		if(npc.getSelected() == YES) {
			if(player.getJob() == 0) {
				player.setJob(400);
				player.giveItem(1332063, 1);
				player.giveItem(1472061, 1);
                                player.giveItem(2070015, 500);
                                player.giveItem(2070015, 500);
                                player.giveItem(2070015, 500);
                                player.setMaxHp(player.getMaxHp() + (100 + random(50)));
                                player.setMaxMp(player.getMaxMp() + (25 + random(25)));
                                player.setStr(4);
                                player.setDex(25);
                                player.setInt(4);
                                player.setLuk(4);
                                player.setAp((player.getLevel() - 1) * 5 - 12);
                                player.setSp((player.getLevel() - 10) * 3 + 1);
                                npc.addText("You now have some understanding of how to fight. It is up to you to train and increase your power.");
				npc.sendOK();
				npc.end();
			}
			else if(player.getJob() == 400) {
					if(player.getItemAmount(4031012) == 1) {
						npc.addText("Choose your path. \r\n#L0#Assassin#l\r\n#L1#Bandit#l");
						npc.sendSimple();
					}
					else{
						player.giveItem(4031011, 1);
                                                npc.addText("If you're sure that you're ready, then take this letter to my assistant so that he may test you. Good luck young thief.");
						npc.sendOK();
						npc.end();
					}
			}
		}
		else{
			npc.addText("Very well.");
			npc.sendOK();
			npc.end();
		}
	}
	else if(state == 2) {
                if (player.getSp() > ((player.getLevel() - 30) * 3)) {
			npc.addText("Hmmm...you have too much SP...you can't make the 2nd job advancement with that many ");
			npc.addText("SP in store. Use more SP on the skills on the 1st level and then come back.");
			npc.sendNext();
                        npc.end();
                        return;
                }
		int type = npc.getSelected();
		npc.setVariable("type", type);
		if(type == 0) {
			player.setJob(410);
			player.setSp(player.getSp() + 1);
                        player.giveItem(4031012, -1);
                        player.setMaxHp(player.getMaxHp() + (300 + random(50)));
                        player.setMaxMp(player.getMaxMp() + (150 + random(50)));
			npc.addText("You are now an Assassin. Train hard, and when you reach level 70, come and talk to me again.");
			npc.sendOK();
			npc.end();
		}
		else if(type == 1) {
			player.setJob(420);
			player.setSp(player.getSp() + 1);
                        player.giveItem(4031012, -1);
                        player.setMaxHp(player.getMaxHp() + (300 + random(50)));
                        player.setMaxMp(player.getMaxMp() + (150 + random(50)));
			npc.addText("You are now a Bandit. Train hard, and when you reach level 70, come and talk to me again.");
			npc.sendOK();
			npc.end();
		}
	}
}